<template>
  <div>
    <el-card class="box-card">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="restaurant.queryInfo.query">
            <el-button slot="append" icon="el-icon-search" @click="handleCurrentChange(1)"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="restaurant.restaurantList" stripe border style="width: 100%">
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="restaurantName" label="店铺">
          <template slot-scope="scope">
            <el-image
                style="width: 100px; height: 100px"
                :src="scope.row.restaurantImg"
                :preview-src-list="[scope.row.restaurantImg]">
            </el-image>
          </template>
        </el-table-column>
        <el-table-column prop="restaurantName" label="店铺名">
        </el-table-column>
        <el-table-column prop="description" label="介绍"></el-table-column>
        <el-table-column prop="address" label="地址"></el-table-column>

        <el-table-column label="操作" width="180px">
          <template slot-scope="scope">
            <el-tooltip :enterable="false" effect="dark" content="进入店铺" placement="top">
              <el-button type="primary" @click="toRestaurantInfo(scope.row.id)" size="mini" >进入店铺</el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>

      <!--:current-page 当前页码-->
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="restaurant.queryInfo.pagenum"
          :page-sizes="[ 4, 6, 8]"
          :page-size="restaurant.queryInfo.pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="restaurant.total">
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "RestaurantCard",
  props: {
    restaurant:{},
  },
  data() {
    return {
      desc: '',
    }
  },
  methods: {
    handleSizeChange (newSize) {
      this.restaurant.queryInfo.pagesize = newSize
      //this.getRestaurantList()
      this.$emit("handleSizeChange",this.restaurant.queryInfo)
    },
    //监听 页码值 改变事件
    handleCurrentChange(newPage) {
      this.restaurant.queryInfo.pagenum = newPage
      this.$emit("handleCurrentChange",this.restaurant.queryInfo)
    },
    toRestaurantInfo: function (restId) {
      this.$router.push({name: 'restaurantInfo', params: {shopId: restId}});

    }
  }
}
</script>

<style scoped>
.image {
  width: 100px;
  display: block;
}
</style>
